home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
wndw40.zip
/
WMGRDEMO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1987-12-11
|
10KB
|
292 lines
{ =========================================================================== }
{ Wmgrdemo.pas - Random-access, multi-level window demo ver 4.0, 12-12-87 }
{ }
{ This program shows you how the window management utilities allow you to }
{ access any window at any time. You can even hide the top level window for }
{ displaying later. }
{ =========================================================================== }
{ Run program.
To make any window come to the top, press the window number.
To move a window (only the top one), leave Scroll Lock on and press arrow
keys, including Home, End, PgDn, PgUp, ^Left-arrrow and ^Right-arrow.
To hide the top level window, press ESC.
To show a hidden window, just press the window number.
To quit, press F10. }
program WindowManager;
{$M 16384, 16384, 16384 }
{$R-,S-,I-,D-,T-,F-,V-,B-,N-,L+ }
uses Crt,Qwik,WndwVars,Wndw;
type
Str80 = string[80];
const
LArr = #75;
RArr = #77;
UArr = #72;
DArr = #80;
HomeKey = #71;
EndKey = #79;
PgUp = #73;
PgDn = #81;
CtrlLArr = #115;
CtrlRArr = #116;
EscKey = #27;
RetKey = #13;
NullKey = #00;
F10Key = #68;
StrA: array[1..5] of Str80 = (
'FORMAT: HideWindow;',
'This procedure simply hides the',
'top level window from the screen',
'which can later be displayed un-',
'altered by ShowWindow.');
StrB: array[1..4] of Str80 = (
'FORMAT: ShowWindow (WindowName: WindowNames);',
'A hidden window can be redisplayed randomly to be',
'the new top level window. Nothing happens if the',
'WindowName is not found among the hidden windows.');
StrC: array[1..7] of Str80 = (
'FORMAT: MoveWindow (Dir: DirType; NumOfChars: byte);',
'The top level window can be moved in any direction and',
'the number of characters (i.e, rows or cols) can also',
'specified. This gives full rate control. This even',
'lets you push a window to its margin limits without',
'calculation. Try ^Left-arrow, ^Right-arrow, PgUp, and',
'PgDn. Shadows are also accommodated.');
StrD: array[1..5] of Str80 = (
'FORMAT: AccessWindow (WindowName: WindowNames);',
'To bring a window to the top level, whether hidden',
'or not, use AccessWindow. All windows are totally',
'managed and fluid. Shadows are permitted, but not',
'fully supported.');
StrE: array[1..5] of Str80 = (
'FORMAT: Attr (Foreground,Background: byte);',
'This is a trivial function that simply con-',
'verts the colors to a byte. However, it is',
'recommended that you use the new background',
'constants instead. See WNDWVARS.PAS.');
StrF: array[1..6] of Str80 = (
'FORMAT: RestoreTurboWindow;',
'If for some reason you jump',
'out of a window, this one',
'will restore Turbo window',
'text colors, window limits,',
'and cursor position.');
StrG: array[1..4] of Str80 = (
'FORMAT: HeapOK (NumOfBytes: word);',
'This function returns true if NumOfBytes',
'is available on the Heap. An error mes-',
'sage is flashed on the screen otherwise.');
StrH: array[1..5] of Str80 = (
'FORMAT: Qbox (Row,Col,Rows,Cols: byte;',
' Wattr,Battr: integer;',
' BorderSel: Borders);',
'Qbox is a subroutine of MakeWindow that',
'simply overwrites the screen with a box.');
StrI: array[1..4] of Str80 = (
'FORMAT: GetLevelIndex (WindowName: WindowNames);',
'This function searches the displayed and then the',
'hidden WndwStats for the first level matching',
'WindowName. Zero is returned if no match is found.');
var
Key: char;
ExtKey: boolean;
ClockReading: longint absolute $0040:$006C; { low memory clock }
TimeAtKbd1: longint;
RowStep,ColStep,FastRowStep,FastColStep,
i,TypematicRate,IdleTime: byte;
procedure DisableInterrupts; inline($FA); { CLI }
procedure EnableInterrupts; inline($FB); { STI }
procedure ReadKbd (VAR ExtKey: boolean; VAR Key: char);
begin
Key:=ReadKey; { Read keyboard input. }
if KeyPressed and (Key=NullKey) then { If first Char was null ... }
begin
Key:=ReadKey; { ... read second char. }
ExtKey := true
end
else ExtKey:=false;
end;
function ScrollLockOn: boolean;
var KeyStat: byte absolute $0000:$0417;
begin
ScrollLockOn:=((KeyStat and $10)<>0); { True if bit 4 set. }
end;
procedure InitStepRates;
begin
TypematicRate:=1; { A maximum of 1 clock tick indicates typematic rate }
if CRTrows>40 then
FastRowStep:=4
else FastRowStep:=2;
FastColStep:=CRTcols div 20;
end;
procedure SetStartTime;
begin
DisableInterrupts;
TimeAtKbd1:=ClockReading;
EnableInterrupts;
end;
procedure AdjustStepRates;
begin
DisableInterrupts;
IdleTime:=ClockReading-TimeAtKbd1;
EnableInterrupts;
if IdleTime<=TypematicRate then
begin
ColStep:=FastColStep;
RowStep:=FastRowStep;
end
else
begin
ColStep:=1;
RowStep:=1;
end;
end;
begin
InitWindow (yellow+BlackBG,true);
InitStepRates;
SetWindowModes (ZoomMode);
MakeWindow ( 1, 2,10,36,black+BrownBG,black+BrownBG,SingleBrdr,Window1);
TitleWindow (Top,Left,' 1 HideWindow ');
with TopWndwStat do
begin
Qwrite (WSrow+2 ,WScol+2,-1,StrA[1]);
for i:=2 to 5 do Qwrite (WSrow+2+i,WScol+2,-1,StrA[i]);
GotoRC (pred(WSrow2),WSwhereC);
end;
MakeWindow ( 3,15, 9,53,black+LightGrayBG,black+LightGrayBG,DoubleBrdr,
Window2);
TitleWindow (Top,Left,' 2 ShowWindow ');
with TopWndwStat do
begin
Qwrite (WSrow+2 ,WScol+2,-1,StrB[1]);
for i:=2 to 4 do Qwrite (WSrow+2+i,WScol+2,-1,StrB[i]);
GotoRC (pred(WSrow2),WSwhereC);
end;
MakeWindow ( 4, 5,12,58,lightred+BlackBG,lightred+BlackBG,HdoubleBrdr,
Window3);
TitleWindow (Top,Left,' 3 MoveWindow ');
with TopWndwStat do
begin
Qwrite (WSrow+2 ,WScol+2,-1,StrC[1]);
for i:=2 to 7 do Qwrite (WSrow+2+i,WScol+2,-1,StrC[i]);
GotoRC (pred(WSrow2),WSwhereC);
end;
MakeWindow ( 6, 9,10,54,white+CyanBG,white+CyanBG,SolidBrdr,Window4);
TitleWindow (Top,Left,' 4 AccessWindow ');
with TopWndwStat do
begin
Qwrite (WSrow+2 ,WScol+2,-1,StrD[1]);
for i:=2 to 5 do Qwrite (WSrow+2+i,WScol+2,-1,StrD[i]);
GotoRC (pred(WSrow2),WSwhereC);
end;
MakeWindow ( 8, 7,10,48,yellow+GreenBG,yellow+GreenBG,EvenSolidBrdr,Window5);
TitleWindow (Top,Left,' 5 Attr ');
with TopWndwStat do
begin
Qwrite (WSrow+2 ,WScol+2,-1,StrE[1]);
for i:=2 to 5 do Qwrite (WSrow+2+i,WScol+2,-1,StrE[i]);
GotoRC (pred(WSrow2),WSwhereC);
end;
MakeWindow (14, 1,11,31,white+BlueBG,white+BlueBG,ThinSolidBrdr2,Window6);
TitleWindow (Top,Left,' 6 RestoreTurboWindow ');
with TopWndwStat do
begin
Qwrite (WSrow+2 ,WScol+2,-1,StrF[1]);
for i:=2 to 6 do Qwrite (WSrow+2+i,WScol+2,-1,StrF[i]);
GotoRC (pred(WSrow2),WSwhereC);
end;
MakeWindow ( 5,37, 9,44,white+MagentaBG,White+MagentaBG,VdoubleBrdr,Window7);
TitleWindow (Top,Left,' 7 HeapOK ');
with TopWndwStat do
begin
Qwrite (WSrow+2 ,WScol+2,-1,StrG[1]);
for i:=2 to 4 do Qwrite (WSrow+2+i,WScol+2,-1,StrG[i]);
GotoRC (pred(WSrow2),WSwhereC);
end;
MakeWindow ( 7,33,10,44,yellow+RedBG,yellow+RedBG,MhatchBrdr,Window8);
TitleWindow (Top,Left,' 8 Qbox ');
with TopWndwStat do
begin
for i:=1 to 3 do Qwrite (WSrow+1+i,WScol+2,-1,StrH[i]);
for i:=4 to 5 do Qwrite (WSrow+2+i,WScol+2,-1,StrH[i]);
GotoRC (pred(WSrow2),WSwhereC);
end;
Ma